<template>
  <h2>我是About</h2>
</template>

<script>
export default {
  name: "About",
  beforeDestroy() {
    console.log('About组件被销毁了')
  },
  mounted() {
    console.log('About组件挂载完毕')
  },
  //路由进入之前,通过路由规则，进入该组件时被调用
  beforeRouteEnter(to,from,next){
    if(to.meta.isAuth){
      if(localStorage.getItem('school')==='gtguigu'){
        next()
      }else {
        alert('名不对，无权限查看')
      }
    }else {
      next()
    }
  },
// ,通过路由规则，离开该组件时被调用,是否允许离开
  beforeRouteLeave(to,from,next){
    // 允许离开
      next()
  }
}
</script>

<style scoped>

</style>